home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12650 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: grantp@usa.pipeline.com(Pete Grant)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: MS VC++ 4.0 namespace weirdness
  5. Date: 21 Mar 1996 00:47:21 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4iq8up$hl3@news1.h1.usa.pipeline.com>
  8. References: <4ip987$aj5@druid.borland.com>
  9. NNTP-Posting-Host: 38.8.60.5
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete Grant)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 20, 1996 15:46:15 in article <Re: MS VC++ 4.0 namespace weirdness>,
  16. 'pete@borland.com (Pete Becker)' wrote: 
  17.  
  18.  
  19. >In article <314D9E46.433@lydian.lc.att.com>, shaw@lydian.lc.att.com
  20. says... 
  21. >> 
  22. >>[Hope this is the right group -- didn't see a VC++-specific one] 
  23. >> 
  24. >>If I define a namespace in an include file, the classes within  
  25. >>that 
  26. >>namespace are not recognized by the MS VC++ 4.0 class window.   
  27. >>If I 
  28. >>define the namespace in the including file, they are.  Any  
  29. >>opinions 
  30. >>on this anomaly? 
  31. >> 
  32. >>        Thanks, 
  33. >>                andrew.shaw@att.com 
  34. >> 
  35. >>Example: 
  36. >> 
  37. >>// foo1.hpp 
  38. >>namespace FOO1 
  39. >>{ 
  40. >>class X1 { int x1; }; 
  41. >>} 
  42. >> 
  43. >>// foo2.hpp 
  44. >>class X2 { int x2; }; 
  45. >> 
  46. >>// foo.cpp 
  47. >>#include "foo1.hpp"     // whereis FOO1::X1? 
  48. >>namespace FOO2 
  49. >>{ 
  50. >>#include "foo2.hpp"     // FOO2::X2 no problem 
  51. >>} 
  52. >Don't do this. I know, Microsoft recommends this as the technique for
  53. getting  
  54. >the public domain version of STL that they slapped onto their CD into a  
  55. >namespace. Bottom line is it doesn't work, and it will cause endless
  56. problems.  
  57. >If the header wasn't written with namespaces in mind don't try to force it
  58. into  
  59. >a namespace. Namespaces are not something you throw in, they're something
  60. you  
  61. >design in. If the design isn't there it's not going to work. 
  62. I guess Pete is referring to case two (FOO2), and I suppose it's sound
  63. advice. 
  64. But it doesn't address the question.   
  65.  
  66. I have used namespace declarations inside header files, as in FOO1 above,  
  67. and have had no problems.  The namespaces behave precisely as expected when
  68.  
  69. compiled with MSVC++4.0/4.1.  I suspect the original poster's problem may
  70. be 
  71. something not shown in the code snippets furnished. 
  72.  
  73. Sample code available upon request. 
  74. -- 
  75. Pete Grant 
  76. Kalevi, Inc. 
  77. Software Engineering & development
  78.